﻿<%@ Page Title="Cash Journal" Language="C#" MasterPageFile="~/Share/MainMenu2.Master"
    EnableEventValidation="false" AutoEventWireup="true" CodeBehind="fCashJournal.aspx.cs"
    Inherits="MixScriptWeb.Accounting.fCashJournal" MaintainScrollPositionOnPostback="true" %>

<%@ Register Src="~/control/MixScriptTB.ascx" TagName="baseTextBox" TagPrefix="mix" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript">

        function Focus(objname, waterMarkText) {
            obj = document.getElementById(objname);
            if (obj.value == waterMarkText) {
                obj.value = "";
            }
        }
        function Blur(objname, waterMarkText) {
            obj = document.getElementById(objname);
            obj.value = waterMarkText;

        }
        function showDetail() {
            document.getElementById("divDetail").style.display = "block";
        }
        function hideDetail() {
            document.getElementById("divDetail").style.display = "none";
        }
        function GetConvert() {
            var ammount = document.getElementById('<%=txtDetAmm.ClientID %>');
            var convert = document.getElementById('<%=txtDetConvert.ClientID %>');
            var rate = document.getElementById('<%=txtDetRate.ClientID %>');
            var hfConv = document.getElementById('<%=hfDetConvert.ClientID %>');
            var hfRate = document.getElementById('<%=hfDetRate.ClientID %>');
            if (ammount.value != "") {
                if (rate.value != "") {
                    convert.value = parseInt(ammount.value) * parseInt(rate.value);
                    hfRate.value = rate.value;
                    hfConv.value = convert.value;
                } else {
                    convert.value = parseInt(ammount.value);
                    hfRate.value = rate.value;
                    hfConv.value = convert.value;
                }
            }
        }

        function showHide() {
            var txtSearch = document.getElementById("<%=txtSearch.ClientID %>")
            var style = txtSearch.style;
            var styletext = txtSearch.style.display
            if (styletext == "none") {
                style.display = "block";
                txtSearch.value = "";
            }
            else if (styletext == "block") {
                style.display = "none";
                FilterItems("");
            }
        }
        var ddlText, ddlValue, ddl, lblMesg;
        function CacheItems() {
            ddlText = new Array();
            ddlValue = new Array();
            ddl = document.getElementById("<%=ddlDetailAccountNo.ClientID %>");
            for (var i = 0; i < ddl.options.length; i++) {
                ddlText[ddlText.length] = ddl.options[i].text;
                ddlValue[ddlValue.length] = ddl.options[i].value;
            }
        }
        window.onload = CacheItems;
        function FilterItems(value) {
            ddl.options.length = 0;
            for (var i = 0; i < ddlText.length; i++) {
                if (ddlText[i].toLowerCase().indexOf(value.toLowerCase()) != -1) {
                    AddItem(ddlText[i], ddlValue[i]);
                }
            }
            if (ddl.options.length == 0) {
                AddItem("No items found.", "");
            }
        }
        function AddItem(text, value) {
            var opt = document.createElement("option");
            opt.text = text;
            opt.value = value;
            ddl.options.add(opt);
        }
    </script>
    <div style="padding-left: 10px;">
        <h2 class="jquery_tab">
            <asp:Label ID="lblTitle" runat="server" Text="General Journal" Font-Bold="True"></asp:Label>
            <asp:HiddenField ID="hdnShow" runat="server" Value="block" />
        </h2>
        <br />
        <table class="table-ui">
            <tr>
                <td style="width: 173px;">
                    Payment Type
                </td>
                <td style="width: 5px;">
                    :
                </td>
                <td>
                    <asp:RadioButtonList ID="rblType" Style="display: inline-block" OnSelectedIndexChanged="rblType_selectedIndex"
                        AutoPostBack="true" runat="server" RepeatDirection="Horizontal" CellSpacing="10">
                        <asp:ListItem Text="Cash" Value="2" Selected="True" />
                        <asp:ListItem Text="Bank" Value="3" />
                    </asp:RadioButtonList>
                </td>
            </tr>
            <tr>
                <td style="width: 173px;">
                    Date
                </td>
                <td style="width: 5px;">
                    :
                </td>
                <td>
                    <asp:TextBox ID="txtDate" CssClass="input-small datepicker" runat="server" Width="122px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="width: 173px;">
                    Number
                </td>
                <td style="width: 5px;">
                    :
                </td>
                <td>
                    <mix:baseTextBox ID="txtFirstNo" runat="server" AllowNull="false" showFind="False"
                        tooltip="" isvalid="True" isPassword="False" tWidht="50" />
                    &nbsp;
                    <mix:baseTextBox ID="txtSecondNo" runat="server" AllowNull="false" showFind="False"
                        tooltip="" isvalid="True" isPassword="False" tWidht="100" />
                </td>
            </tr>
            <tr>
                <td style="width: 173px; height: 28px;">
                    Currency
                </td>
                <td style="width: 5px; height: 28px;">
                    :
                </td>
                <td style="width: 100px;">
                    <asp:DropDownList ID="ddlCurrency" runat="server">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td style="width: 150px;">
                    Description
                </td>
                <td style="width: 5px;">
                    :
                </td>
                <td style="width: 1000px;">
                    <mix:baseTextBox ID="txtDescription" runat="server" AllowNull="false" showFind="False"
                        tooltip="" isvalid="True" isPassword="False" tWidht="400" />
                </td>
            </tr>
        </table>
        <br />
        <table width="100%" class="table-ui" style="background-color: #DCDCDC;">
            <tr>
                <td style="width: 7%">
                    Account
                </td>
                <td colspan="2" style="width: 20%">
                    :&nbsp;<asp:DropDownList ID="ddlCashAccount" Width="90%" runat="server" />
                </td>
                <td style="width: 10%">
                    Description
                </td>
                <td colspan="4" style="width: 40%">
                    &nbsp;
                    <mix:baseTextBox ID="txtCashDescripiton" tWidht="90%" AllowNull="false" showFind="False"
                        tooltip="" isvalid="True" isPassword="False" runat="server" Text="" />
                </td>
                <td colspan="2" style="width: 23%">
                    <asp:Panel ID="pnlType" Style="display: none" runat="server">
                        Bank :
                        <asp:DropDownList ID="ddlBank" runat="server" />
                    </asp:Panel>
                </td>
            </tr>
            <tr>
                <td>
                    Curr
                </td>
                <td>
                    : &nbsp<asp:DropDownList ID="ddlCashCurrency" runat="server" AutoPostBack="true"
                        OnSelectedIndexChanged="ddlCashCurrency_indexChange" />
                </td>
                <td>
                    Kurs
                </td>
                <td>
                    : &nbsp<asp:DropDownList ID="ddlCashKurs" runat="server">
                        <asp:ListItem Text="Pajak" Value="Pajak" />
                        <asp:ListItem Text="Jual" Value="Jual" />
                        <asp:ListItem Text="Beli" Value="Beli" />
                    </asp:DropDownList>
                </td>
                <td>
                    Rate
                </td>
                <td>
                    : &nbsp
                    <asp:TextBox ID="txtCashRate" runat="server" ToolTip="" Widht="200" CssClass="input-set"
                        ReadOnly="true" Text="1" BackColor="Gray" />
                </td>
                <td>
                    <asp:Label runat="server" Text="" ID="lblDC"></asp:Label>
                </td>
                <td>
                    : &nbsp<mix:baseTextBox ID="txtCashCredit" runat="server" AllowNull="false" showFind="False"
                        tooltip="" isvalid="True" isPassword="False" tWidht="120" />
                </td>
                <td>
                    Convert
                </td>
                <td>
                    : &nbsp<mix:baseTextBox ID="txtCashConvert" runat="server" AllowNull="false" showFind="False"
                        tooltip="" isvalid="True" isPassword="False" tWidht="100" ReadOnly="true" />
                </td>
            </tr>
        </table>
        <br />
        <asp:Panel ID="pnl1" runat="server" ScrollBars="Both" Height="250px" BackColor="Control">
            <asp:GridView BorderColor="Gray" ID="gvdetail" runat="server" Width="150%" AutoGenerateColumns="False"
                OnRowCommand="gvdetail_RowCommand">
                <AlternatingRowStyle CssClass="alt" />
                <HeaderStyle Height="40px" HorizontalAlign="Justify" />
                <Columns>
                    <asp:TemplateField HeaderText="Edit">
                        <ItemTemplate>
                            <asp:LinkButton CommandName="Updated" Text="Edit" ID="lbEdit" runat="server" CommandArgument='<%# Bind("No") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Delete">
                        <ItemTemplate>
                            <asp:LinkButton CommandName="Deleted" Text="Delete" ID="lbDelete" runat="server"
                                CommandArgument='<%# Bind("No") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="No" HeaderText="NO" />
                    <asp:BoundField DataField="Acct" HeaderText="ACCT" />
                    <asp:BoundField DataField="Description" HeaderText="DESCRIPTION" />
                    <asp:BoundField DataField="Currency" HeaderText="CURRENCY" />
                    <asp:BoundField DataField="Rate" HeaderText="RATE" />
                    <asp:BoundField DataField="Ammount" HeaderText="AMMOUNT" ItemStyle-HorizontalAlign="Right"
                        DataFormatString="{0:##,##.00}" />
                    <asp:BoundField DataField="Debit" HeaderText="DEBIT" ItemStyle-HorizontalAlign="Right"
                        DataFormatString="{0:##,##.00}" />
                    <asp:BoundField DataField="Credit" HeaderText="CREDIT" ItemStyle-HorizontalAlign="Right"
                        DataFormatString="{0:##,##.00}" />
                    <asp:BoundField DataField="Process" HeaderText="PROCESS" ItemStyle-HorizontalAlign="Center" />
                    <asp:BoundField DataField="subsidiary" HeaderText="SUBSIDIARY" />
                    <asp:BoundField DataField="Invoice" HeaderText="INVOICE" />
                    <asp:BoundField DataField="InvoiceDate" HeaderText="INV-DATE" DataFormatString="{0:dd-MM-yyyy}" />
                    <asp:BoundField DataField="Terms" HeaderText="TERMS" />
                </Columns>
                <EditRowStyle BorderColor="Silver" BorderStyle="Solid" />
                <FooterStyle CssClass="ft" />
                <PagerStyle BorderStyle="None" BorderWidth="0px" HorizontalAlign="Center" />
            </asp:GridView>
        </asp:Panel>
        <br />
        Debet&nbsp;:&nbsp;
        <mix:baseTextBox ID="txtSumDebet" runat="server" Text="0" Enabled="true" isvalid="true"
            isPassword="false" showFind="false" ReadOnly="true" />
        &nbsp;&nbsp;&nbsp;Kredit&nbsp;:&nbsp;
        <mix:baseTextBox ID="txtSumKredit" runat="server" Text="0" Enabled="true" isvalid="true"
            isPassword="false" showFind="false" ReadOnly="true" />
        &nbsp;&nbsp;&nbsp;Total&nbsp;:&nbsp;
        <mix:baseTextBox ID="txtSumTotal" runat="server" Text="0" Enabled="true" isvalid="true"
            isPassword="false" showFind="false" ReadOnly="true" />
        <br />
        <%--<button id="btnNew" type="button" class="button" style="width: 99px" onclick="showDetail();">
            Add Detail</button>--%>
        <table class="table-ui" width="100%">
            <tr>
                <td align="right">
                    <asp:Button ID="btnSaveAll" runat="server" CssClass="button" Text="Save Journal"
                        Width="99px" OnClick="btnSaveAll_click" />
                    <asp:Button ID="btnReset" runat="server" CssClass="button" Text="Reset" Width="99px" />
                </td>
            </tr>
        </table>
        <div id="divDetail" style="background-color: #DCDCDC; font-size: 12px; width: 100%"
            title="Detail">
            <table style="width: 100%;" class="table-ui">
                <tr>
                    <td colspan="9">
                        <h2>
                            Detail</h2>
                    </td>
                </tr>
                <tr>
                    <td style="width: 10%">
                        Account
                    </td>
                    <td style="width: 40%" colspan="5">
                        <asp:TextBox ID="txtSearch" runat="server" Width="63%" ToolTip="Type Filter Here, after that select account below"
                            Style="display: none" onfocus="Focus(this.id,'')" onblur="Blur(this.id,'PLEASE INPUT FILTER HERE')"
                            onkeyup="FilterItems(this.value)" CssClass="input-set"></asp:TextBox>
                        <asp:DropDownList ID="ddlDetailAccountNo" runat="server" Width="300" AutoPostBack="true"
                            OnSelectedIndexChanged="ddlDetailAccountNo_indexChange">
                        </asp:DropDownList>
                        <input type="checkbox" id="sh" title="filter" onclick="showHide()" /><br />
                    </td>
                    <td style="width: 30%">
                        &nbsp;&nbsp;Subsidiary
                    </td>
                    <td style="width: 20%" colspan="2">
                        <asp:DropDownList ID="ddlSubsidiaryNo" runat="server" Width="300" Enabled="false"
                            AutoPostBack="true" OnSelectedIndexChanged="ddlDetailDC_selectedChange">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td>
                        Currency
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlDetailCurrency" runat="server" Width="70px" AutoPostBack="true"
                            OnSelectedIndexChanged="ddlDetailCurrency_indexChange">
                        </asp:DropDownList>
                    </td>
                    <td>
                        Kurs
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlDetailKurs" runat="server" Width="70px" AutoPostBack="true"
                            OnSelectedIndexChanged="ddlDetailCurrency_indexChange">
                            <asp:ListItem Text="Pajak" Value="Pajak" />
                            <asp:ListItem Text="Jual" Value="Jual" />
                            <asp:ListItem Text="Beli" Value="Beli" />
                        </asp:DropDownList>
                    </td>
                    <td>
                        Rate
                    </td>
                    <td>
                        <asp:TextBox ID="txtDetRate" runat="server" ToolTip="" Widht="100" CssClass="input-set"
                            ReadOnly="true" BackColor="Gray" />
                        <%--<mix:baseTextBox ID="txtDetailRate" runat="server" AllowNull="false" showFind="False"
                            tooltip="" isvalid="true" isPassword="False" tWidht="60" />--%>
                    </td>
                    <td>
                        &nbsp;&nbsp;invoice
                    </td>
                    <td colspan="2">
                        <asp:Panel ID="pnlInvoiceText" runat="server" Style="display: block">
                            <mix:baseTextBox ID="txtDetailInvoice" runat="server" AllowNull="false" showFind="False"
                                tooltip="" isvalid="true" isPassword="False" />
                        </asp:Panel>
                        <asp:Panel ID="pnlInvoiceSel" runat="server" Style="display: none">
                            <asp:DropDownList ID="ddlInvoice" runat="server" />
                        </asp:Panel>
                    </td>
                </tr>
                <tr>
                    <td>
                        D/C
                    </td>
                    <td colspan="5">
                        <asp:DropDownList ID="ddlDetailDC" runat="server" Width="70px" AutoPostBack="true"
                            OnSelectedIndexChanged="ddlDetailDC_selectedChange">
                            <asp:ListItem Value="D" Text="Debit" />
                            <asp:ListItem Value="C" Text="Credit" />
                        </asp:DropDownList>
                    </td>
                    <td>
                        &nbsp;&nbsp;Date
                    </td>
                    <td colspan="2">
                        <asp:TextBox runat="server" ID="txtDetailDate" CssClass="input-small datepicker" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Ammount
                    </td>
                    <td colspan="2">
                        <asp:TextBox ID="txtDetAmm" runat="server" ToolTip="" Widht="100" CssClass="input-set" />
                        <%--<mix:baseTextBox ID="txtDetailAmmount" runat="server" AllowNull="false" showFind="False"
                            tooltip="" isvalid="true" isPassword="False" tWidht="100" />--%>
                    </td>
                    <td>
                        Convert
                    </td>
                    <td colspan="2">
                        <asp:TextBox ID="txtDetConvert" runat="server" ToolTip="" Widht="95" CssClass="input-set"
                            ReadOnly="true" />
                        <%--<mix:baseTextBox ID="txtDetailConvert" runat="server" AllowNull="false" showFind="False"
                            tooltip="" isvalid="True" isPassword="False" tWidht="95" />--%>
                        <asp:HiddenField ID="hfDetConvert" runat="server" />
                        <asp:HiddenField ID="hfDetRate" runat="server" />
                    </td>
                    <td>
                        &nbsp;&nbsp;Terms Of Payment
                    </td>
                    <td colspan="2">
                        <mix:baseTextBox ID="txtDetailTerms" runat="server" AllowNull="false" showFind="False"
                            tooltip="" isvalid="true" isPassword="False" />
                    </td>
                </tr>
                <tr>
                    <td colspan="6">
                    </td>
                    <td>
                        &nbsp;&nbsp;Po Invoice No
                    </td>
                    <td>
                        <mix:baseTextBox ID="txtPoInvice" runat="server" AllowNull="false" showFind="False"
                            tooltip="" isvalid="true" isPassword="False" />
                    </td>
                </tr>
                <tr>
                    <td colspan="6">
                    </td>
                    <td>
                        &nbsp;&nbsp;Po Invoice Date
                    </td>
                    <td>
                        <asp:TextBox runat="server" ID="txtPoInvoiceDate" CssClass="input-small datepicker" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Description
                    </td>
                    <td colspan="8">
                        <mix:baseTextBox ID="txtDetailDescription" runat="server" AllowNull="false" showFind="False"
                            tooltip="" isvalid="true" isPassword="False" tWidht="95%" />
                    </td>
                </tr>
                <tr>
                    <td>
                    </td>
                    <td colspan="8">
                        <asp:Button ID="btnDetailSave" runat="server" Text="Save" CssClass="button" Width="99px"
                            OnClick="btnSave_click" />
                        <button id="btnDetailClose" type="button" class="button" style="width: 99px; display: none"
                            onclick="hideDetail();">
                            Close</button>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</asp:Content>
